python os remove file

43

Delete file in python Using the os module -

import os
if os.path.isfile('/Users/test/new_file.txt'):
    os.remove('/Users/test/new_file.txt')
    print("success")
else:    
    print("File doesn't exists!")

Comments

Submit
0 Comments